package com.tenton.controller;

import com.tenton.service.SupplierService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @Date: 2021/1/9
 * @Author: Tenton
 * @Description:
 */
@ApiIgnore
@Controller
@ApiOperation("员工供应商管理")
@RequestMapping("/employee/flatform/supplier")
public class SupplierController {
    @Autowired
    SupplierService supplierService;

    /**
     * 获取所有供应商信息
     *
     * @param model
     * @param pn
     * @return
     */
    @ApiOperation("获取所有供应商信息")
    @GetMapping("/getAll")
    public String getAll_sup(ModelMap model,
                             @ApiParam("页码") @RequestParam(defaultValue = "1", required = true, value = "pn") Integer pn
    ) {
        supplierService.getAll(pn, model);
        return "employee/supplier/getSupplierList";

    }

    /**
     * 供应商名称模糊查询
     *
     * @param supName
     * @param pn
     * @param model
     * @return
     */
    @ApiOperation("供应商名称模糊查询")
    @GetMapping("/getByParams")
    public String getByParams(@ApiParam("供应商公司名") @RequestParam(value = "supName", required = false) String supName,
                              @ApiParam("页码") @RequestParam(defaultValue = "1", required = true, value = "pn") Integer pn,
                              Model model) {
        supplierService.getByParams(supName, pn, model);
        return "employee/supplier/getSupplierByParams";
    }
}
